home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Snippets / PaletteAnimation 1.0.2 / PaletteAnimation.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-01  |  1.4 KB  |  76 lines  |  [TEXT/CWIE]

  1. // PaletteAnimation
  2. // version 1.0.2
  3. // by Ken Long <kenlong@netcom.com>
  4. // updated for CW7 on 951201
  5.  
  6. # include <Palettes.h>
  7.  
  8.  
  9. # define BASE_RES_ID        400
  10. # define NIL_POINTER        0L
  11. # define MOVE_TO_FRONT        -1L
  12. # define CLUT_ID            130
  13. # define PALETTE_ID            1288
  14. # define SRC_USAGE            2
  15. # define SRC_TOLERANCE        0
  16. # define REMOVE_ALL_EVENTS    0
  17.  
  18.  
  19. WindowPtr        gHelloWindow;
  20. RGBColor        myRGB;    
  21. Point            *mouseLoc;
  22. int                x,y,c;
  23. PaletteHandle    gThePalette;
  24. CTabHandle        gTheCLUT;
  25.  
  26.  
  27.  
  28. /******************** Main ********************/
  29. main()
  30. {
  31.     ToolBoxInit();
  32.     WindowInit();
  33. }
  34.  
  35.  
  36.  
  37. /******************** ToolBoxInit ********************/
  38. ToolBoxInit()
  39.  
  40. {
  41.     InitGraf ( &qd.thePort );
  42.     InitFonts();
  43.     FlushEvents ( everyEvent,  0 );
  44.     InitWindows();
  45.     InitMenus();
  46.     TEInit();
  47.     InitDialogs( 0L );
  48.     InitCursor();
  49. }
  50.  
  51.  
  52. /******************** WindowInit ********************/
  53. WindowInit ()
  54. {    
  55.  
  56.     gHelloWindow = GetNewCWindow ( BASE_RES_ID, 0L, (WindowPtr)-1L );
  57.     SetPort ( gHelloWindow );
  58.     gTheCLUT = GetCTable ( CLUT_ID );
  59.     gThePalette = GetNewPalette ( PALETTE_ID );
  60.     CTab2Palette ( gTheCLUT, gThePalette, 2, 0);
  61.     SetPalette ( gHelloWindow, gThePalette, TRUE );
  62.     ActivatePalette ( gHelloWindow );
  63.     while (!Button())
  64.     {
  65.         y = 500;
  66.         for (c = 1; c < 255; c++ )
  67.         {
  68.             x++;
  69.             MoveTo ( x, y );
  70.             GetEntryColor ( gThePalette, c, &myRGB );
  71.             RGBForeColor ( &myRGB );
  72.             GetMouse ( mouseLoc );
  73.             LineTo ( x, 0 );
  74.         }    
  75.     }
  76. }